package com.biosimilarity.naturalselection.model.dataset;

import com.biosimilarity.naturalselection.model.dataset.Absyn.*;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;

/** BNFC-Generated Fold Visitor */
public abstract class FoldVisitor<R,A> implements AllVisitor<R,A> {
    public abstract R leaf(A arg);
    public abstract R combine(R x, R y, A arg);

/* RecordExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Joined p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordexpr_1.accept(this, arg), r, arg);
      r = combine(p.recordexpr_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Isolated p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordexpr_1.accept(this, arg), r, arg);
      r = combine(p.recordexpr_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Consed p, A arg) {
      R r = leaf(arg);
      r = combine(p.tupleexpr_.accept(this, arg), r, arg);
      r = combine(p.recordexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Contexted p, A arg) {
      R r = leaf(arg);
      for (Binding x : p.listbinding_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      r = combine(p.recordexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Referenced p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordvariable_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Collected p, A arg) {
      R r = leaf(arg);
      r = combine(p.collectionexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Emptied p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* Binding */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.BindingExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordptn_1.accept(this, arg), r, arg);
      r = combine(p.recordptn_2.accept(this, arg), r, arg);
      return r;
    }

/* RecordPtn */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.RecordDestructor p, A arg) {
      R r = leaf(arg);
      for (TuplePtn x : p.listtupleptn_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      r = combine(p.recordptn_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.RecordLiteral p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordexpr_.accept(this, arg), r, arg);
      return r;
    }

/* RecordVariable */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.RecordIdent p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.RecordWild p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* CollectionExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Extension p, A arg) {
      R r = leaf(arg);
      r = combine(p.fieldformals_.accept(this, arg), r, arg);
      r = combine(p.extensionbodyexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Intension p, A arg) {
      R r = leaf(arg);
      r = combine(p.fieldformals_.accept(this, arg), r, arg);
      r = combine(p.intensionbodyexpr_.accept(this, arg), r, arg);
      return r;
    }

/* FieldFormals */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.FieldFormalSpec p, A arg) {
      R r = leaf(arg);
      for (FieldExpr x : p.listfieldexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }

/* ExtensionBodyExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ExtensionBody p, A arg) {
      R r = leaf(arg);
      for (TupleExpr x : p.listtupleexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }

/* IntensionBodyExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.IntensionBody p, A arg) {
      R r = leaf(arg);
      r = combine(p.tupleptn_.accept(this, arg), r, arg);
      for (TupleDeclOrCond x : p.listtupledeclorcond_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }

/* FieldExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.FieldDecl p, A arg) {
      R r = leaf(arg);
      r = combine(p.fieldname_.accept(this, arg), r, arg);
      r = combine(p.fieldtype_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.FieldActual p, A arg) {
      R r = leaf(arg);
      r = combine(p.fieldname_.accept(this, arg), r, arg);
      return r;
    }

/* FieldName */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.FieldIdent p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* TupleExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleSumExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.tupleexpr_1.accept(this, arg), r, arg);
      r = combine(p.tupleexpr_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleBaseExpr p, A arg) {
      R r = leaf(arg);
      for (ValueExpr x : p.listvalueexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleMultExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.tupleexpr_1.accept(this, arg), r, arg);
      r = combine(p.tupleexpr_2.accept(this, arg), r, arg);
      return r;
    }

/* TupleDeclOrCond */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ConditionIn p, A arg) {
      R r = leaf(arg);
      r = combine(p.tuplecond_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.DeclIn p, A arg) {
      R r = leaf(arg);
      r = combine(p.tuplegen_.accept(this, arg), r, arg);
      return r;
    }

/* TuplePtn */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TuplePtnExpr p, A arg) {
      R r = leaf(arg);
      for (ValueExpr x : p.listvalueexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }

/* TupleGen */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleGenExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.tupleptn_.accept(this, arg), r, arg);
      r = combine(p.recordexpr_.accept(this, arg), r, arg);
      return r;
    }

/* TupleCond */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleSatExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.tupleptn_.accept(this, arg), r, arg);
      r = combine(p.tuplecondition_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleCompExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.valueexpr_1.accept(this, arg), r, arg);
      r = combine(p.comparison_.accept(this, arg), r, arg);
      r = combine(p.valueexpr_2.accept(this, arg), r, arg);
      return r;
    }

/* TupleCondition */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.DisjunctTupleCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.tuplecondition_1.accept(this, arg), r, arg);
      r = combine(p.tuplecondition_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ConjunctTupleCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.tuplecondition_1.accept(this, arg), r, arg);
      r = combine(p.tuplecondition_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.NegatedTupleCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.tuplecondition_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.StructuralTupleCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.structuretuplecondition_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.BaseTupleCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.groundtuplecondition_.accept(this, arg), r, arg);
      return r;
    }

/* StructureTupleCondition */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleValCond p, A arg) {
      R r = leaf(arg);
      for (ValueCondition x : p.listvaluecondition_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }

/* GroundTupleCondition */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleLogicGround p, A arg) {
      R r = leaf(arg);
      r = combine(p.logicalground_.accept(this, arg), r, arg);
      return r;
    }

/* ValueCondition */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.DisjunctValueCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.valuecondition_1.accept(this, arg), r, arg);
      r = combine(p.valuecondition_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ConjunctValueCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.valuecondition_1.accept(this, arg), r, arg);
      r = combine(p.valuecondition_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.NegatedValueCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.valuecondition_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.StructuralValueCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.structurevaluecondition_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.BaseValueCondition p, A arg) {
      R r = leaf(arg);
      r = combine(p.groundvaluecondition_.accept(this, arg), r, arg);
      return r;
    }

/* GroundValueCondition */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueLogicGround p, A arg) {
      R r = leaf(arg);
      r = combine(p.logicalground_.accept(this, arg), r, arg);
      return r;
    }

/* StructureValueCondition */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueRecCond p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordcondition_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueListCond p, A arg) {
      R r = leaf(arg);
      for (ValueCondition x : p.listvaluecondition_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueSetCond p, A arg) {
      R r = leaf(arg);
      for (ValueCondition x : p.listvaluecondition_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueLitCond p, A arg) {
      R r = leaf(arg);
      r = combine(p.valueliteral_.accept(this, arg), r, arg);
      return r;
    }

/* RecordCondition */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueRecBodyCond p, A arg) {
      R r = leaf(arg);
      for (TupleCondition x : p.listtuplecondition_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      r = combine(p.recordcondition_.accept(this, arg), r, arg);
      return r;
    }

/* LogicalGround */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Verity p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Absurdity p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Nullity p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* FieldType */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.FieldTypeExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.typeexpr_.accept(this, arg), r, arg);
      return r;
    }

/* TypeExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ArrayTypeExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.typeexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.RcrdTypeExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.typeformals_.accept(this, arg), r, arg);
      for (TypeExpr x : p.listtypeexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.RecTypeExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.typename_.accept(this, arg), r, arg);
      r = combine(p.typeexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.RefTypeExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.typename_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.CollTypeExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.colltype_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.GroundTypeExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.groundtype_.accept(this, arg), r, arg);
      return r;
    }

/* CollType */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.LListTypeExpr p, A arg) {
      R r = leaf(arg);
      for (TypeExpr x : p.listtypeexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.SetTypeExpr p, A arg) {
      R r = leaf(arg);
      for (TypeExpr x : p.listtypeexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TupleTypeExpr p, A arg) {
      R r = leaf(arg);
      for (TypeExpr x : p.listtypeexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }

/* TypeName */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TypeIdent p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* GroundType */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.GroundInteger p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.GroundDouble p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.GroundString p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.GroundChar p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* TypeFormals */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.TypeParameters p, A arg) {
      R r = leaf(arg);
      for (TypeExpr x : p.listtypeexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }

/* Comparison */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Equality p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.Less p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.More p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.LEq p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.GEq p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* ValueExpr */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueAddExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.valueexpr_1.accept(this, arg), r, arg);
      r = combine(p.valueexpr_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueMultExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.valueexpr_1.accept(this, arg), r, arg);
      r = combine(p.valueexpr_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueArrAccExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.valueexpr_1.accept(this, arg), r, arg);
      r = combine(p.valueexpr_2.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueNegExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.valueexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueVarExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.valuevariable_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueLitExpr p, A arg) {
      R r = leaf(arg);
      r = combine(p.valueliteral_.accept(this, arg), r, arg);
      return r;
    }

/* ValueVariable */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueIdent p, A arg) {
      R r = leaf(arg);
      return r;
    }

/* ValueLiteral */
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueRecLit p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueRecProjLit p, A arg) {
      R r = leaf(arg);
      r = combine(p.recordexpr_.accept(this, arg), r, arg);
      r = combine(p.fieldexpr_.accept(this, arg), r, arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueListLit p, A arg) {
      R r = leaf(arg);
      for (ValueExpr x : p.listvalueexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueSetLit p, A arg) {
      R r = leaf(arg);
      for (ValueExpr x : p.listvalueexpr_) {
        r = combine(x.accept(this,arg), r, arg);
      }
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueIntLit p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueDoubleLit p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueStringLit p, A arg) {
      R r = leaf(arg);
      return r;
    }
    public R visit(com.biosimilarity.naturalselection.model.dataset.Absyn.ValueCharLit p, A arg) {
      R r = leaf(arg);
      return r;
    }


}
